package servlet.book;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.javabean.BookBean;
import com.sql.Book;


@WebServlet("/addBook")
public class AddBook extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
    public AddBook() {
        super();
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		
		String bookname = request.getParameter("bookname");
		String author = request.getParameter("author");
		String publisher = request.getParameter("publisher");
		String address = request.getParameter("address");
		String ISBN = request.getParameter("isbn");
		String clc = request.getParameter("clc");
		String prices = request.getParameter("prices");
		String pages = request.getParameter("pages");
		String format = request.getParameter("format");
		String store = request.getParameter("store");
		String content = request.getParameter("content");
		String catalog = request.getParameter("catalog");
		
		BookBean bBean = new BookBean();
		bBean.setBookname(bookname);
		bBean.setAuthor(author);
		bBean.setPublisher(publisher);
		bBean.setAddress(address);
		bBean.setIsbn(ISBN);
		bBean.setCLC(clc);
		bBean.setPrices(prices);
		bBean.setFormat(format);
		bBean.setPages(pages);
		bBean.setStore(Integer.parseInt(store));
		bBean.setContent(content);
		bBean.setCatalog(catalog);
		
		Book book = new Book();
		book.addBook(bBean);
		
		request.getRequestDispatcher("managebook").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
